#include<stdio.h>
int main()
{
	int n,l,k,y;
	int min=1<<31-1;
	scanf("%d%d%d%d",&n,&l,&k,&y);
	int a=l+k+y,b=l+l+k,c=3*l+3*k+2*y;
	getchar();
	for(int i=0;i<n;i++)
	{
		char tem;
		int sum=0;
		while((tem=getchar())!='\n')
		{
			switch(tem)
			{
				case 'A':
					sum+=a;
					break;
				case 'B':
					sum+=b;
					break;
				case 'C':
					sum+=c;
					break;
			}
		}
		if(sum<min)
		{
			min=sum;
		}
	}
	printf("%d",min);
	return 0;
}
